%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left


    %% plan dependencies
    Object17{{"Object[17∈0]<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access15{{"Access[15∈0]<br />ᐸ3.pgSettingsᐳ"}}:::plan
    Access16{{"Access[16∈0]<br />ᐸ3.withPgClientᐳ"}}:::plan
    Access15 & Access16 --> Object17
    __Value3["__Value[3∈0]<br />ᐸcontextᐳ"]:::plan
    __Value3 --> Access15
    __Value3 --> Access16
    __Value0["__Value[0∈0]"]:::plan
    __Value5["__Value[5∈0]<br />ᐸrootValueᐳ"]:::plan
    Constant57{{"Constant[57∈0]<br />ᐸ'2023-05-24T07:43:00Z'ᐳ"}}:::plan
    Constant58{{"Constant[58∈0]<br />ᐸ'temp'ᐳ"}}:::plan
    Constant59{{"Constant[59∈0]<br />ᐸ12.7ᐳ"}}:::plan
    Constant60{{"Constant[60∈0]<br />ᐸ4ᐳ"}}:::plan
    Constant63{{"Constant[63∈0]<br />ᐸ13ᐳ"}}:::plan
    PgInsertSingle14[["PgInsertSingle[14∈1]<br />ᐸmeasurements(timestamp,key,value,user_id)ᐳ"]]:::sideeffectplan
    Object17 & Constant57 & Constant58 & Constant59 & Constant60 --> PgInsertSingle14
    Object18{{"Object[18∈1]<br />ᐸ{result}ᐳ"}}:::plan
    PgInsertSingle14 --> Object18
    PgSelect23[["PgSelect[23∈3]<br />ᐸusersᐳ"]]:::plan
    PgClassExpression22{{"PgClassExpression[22∈3]<br />ᐸ__measurem....”user_id”ᐳ"}}:::plan
    Object17 & PgClassExpression22 --> PgSelect23
    PgClassExpression19{{"PgClassExpression[19∈3]<br />ᐸ__measurem...timestamp”ᐳ"}}:::plan
    PgInsertSingle14 --> PgClassExpression19
    PgClassExpression20{{"PgClassExpression[20∈3]<br />ᐸ__measurements__.”key”ᐳ"}}:::plan
    PgInsertSingle14 --> PgClassExpression20
    PgClassExpression21{{"PgClassExpression[21∈3]<br />ᐸ__measurem...__.”value”ᐳ"}}:::plan
    PgInsertSingle14 --> PgClassExpression21
    PgInsertSingle14 --> PgClassExpression22
    First27{{"First[27∈3]"}}:::plan
    PgSelect23 --> First27
    PgSelectSingle28{{"PgSelectSingle[28∈3]<br />ᐸusersᐳ"}}:::plan
    First27 --> PgSelectSingle28
    PgClassExpression29{{"PgClassExpression[29∈4]<br />ᐸ__users__.”id”ᐳ"}}:::plan
    PgSelectSingle28 --> PgClassExpression29
    PgClassExpression30{{"PgClassExpression[30∈4]<br />ᐸ__users__.”name”ᐳ"}}:::plan
    PgSelectSingle28 --> PgClassExpression30
    PgUpdateSingle40[["PgUpdateSingle[40∈5]<br />ᐸmeasurements(timestamp,key;value)ᐳ"]]:::sideeffectplan
    Object43{{"Object[43∈5]<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Object43 & Constant57 & Constant58 & Constant63 --> PgUpdateSingle40
    Access41{{"Access[41∈5]<br />ᐸ3.pgSettingsᐳ"}}:::plan
    Access42{{"Access[42∈5]<br />ᐸ3.withPgClientᐳ"}}:::plan
    Access41 & Access42 --> Object43
    __Value3 --> Access41
    __Value3 --> Access42
    Object44{{"Object[44∈5]<br />ᐸ{result}ᐳ"}}:::plan
    PgUpdateSingle40 --> Object44
    PgSelect49[["PgSelect[49∈7]<br />ᐸusersᐳ"]]:::plan
    PgClassExpression48{{"PgClassExpression[48∈7]<br />ᐸ__measurem....”user_id”ᐳ"}}:::plan
    Object43 & PgClassExpression48 --> PgSelect49
    PgClassExpression45{{"PgClassExpression[45∈7]<br />ᐸ__measurem...timestamp”ᐳ"}}:::plan
    PgUpdateSingle40 --> PgClassExpression45
    PgClassExpression46{{"PgClassExpression[46∈7]<br />ᐸ__measurements__.”key”ᐳ"}}:::plan
    PgUpdateSingle40 --> PgClassExpression46
    PgClassExpression47{{"PgClassExpression[47∈7]<br />ᐸ__measurem...__.”value”ᐳ"}}:::plan
    PgUpdateSingle40 --> PgClassExpression47
    PgUpdateSingle40 --> PgClassExpression48
    First53{{"First[53∈7]"}}:::plan
    PgSelect49 --> First53
    PgSelectSingle54{{"PgSelectSingle[54∈7]<br />ᐸusersᐳ"}}:::plan
    First53 --> PgSelectSingle54
    PgClassExpression55{{"PgClassExpression[55∈8]<br />ᐸ__users__.”id”ᐳ"}}:::plan
    PgSelectSingle54 --> PgClassExpression55
    PgClassExpression56{{"PgClassExpression[56∈8]<br />ᐸ__users__.”name”ᐳ"}}:::plan
    PgSelectSingle54 --> PgClassExpression56

    %% define steps

    subgraph "Buckets for mutations/v4/partitions"
    Bucket0("Bucket 0 (root)"):::bucket
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value3,__Value5,Access15,Access16,Object17,Constant57,Constant58,Constant59,Constant60,Constant63 bucket0
    Bucket1("Bucket 1 (mutationField)<br />Deps: 17, 57, 58, 59, 60<br /><br />1: PgInsertSingle[14]<br />2: <br />ᐳ: Object[18]"):::bucket
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgInsertSingle14,Object18 bucket1
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 18, 14, 17<br /><br />ROOT Object{1}ᐸ{result}ᐳ[18]"):::bucket
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 14, 17<br /><br />ROOT PgInsertSingle{1}ᐸmeasurements(timestamp,key,value,user_id)ᐳ[14]<br />1: <br />ᐳ: 19, 20, 21, 22<br />2: PgSelect[23]<br />ᐳ: First[27], PgSelectSingle[28]"):::bucket
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression19,PgClassExpression20,PgClassExpression21,PgClassExpression22,PgSelect23,First27,PgSelectSingle28 bucket3
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 28<br /><br />ROOT PgSelectSingle{3}ᐸusersᐳ[28]"):::bucket
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression29,PgClassExpression30 bucket4
    Bucket5("Bucket 5 (mutationField)<br />Deps: 57, 58, 63, 3<br /><br />1: Access[41]<br />2: Access[42]<br />3: Object[43]<br />4: PgUpdateSingle[40]<br />5: <br />ᐳ: Object[44]"):::bucket
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgUpdateSingle40,Access41,Access42,Object43,Object44 bucket5
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 44, 40, 43<br /><br />ROOT Object{5}ᐸ{result}ᐳ[44]"):::bucket
    classDef bucket6 stroke:#ff1493
    class Bucket6 bucket6
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 40, 43<br /><br />ROOT PgUpdateSingle{5}ᐸmeasurements(timestamp,key;value)ᐳ[40]<br />1: <br />ᐳ: 45, 46, 47, 48<br />2: PgSelect[49]<br />ᐳ: First[53], PgSelectSingle[54]"):::bucket
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression45,PgClassExpression46,PgClassExpression47,PgClassExpression48,PgSelect49,First53,PgSelectSingle54 bucket7
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 54<br /><br />ROOT PgSelectSingle{7}ᐸusersᐳ[54]"):::bucket
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgClassExpression55,PgClassExpression56 bucket8
    Bucket0 --> Bucket1 & Bucket5
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    Bucket5 --> Bucket6
    Bucket6 --> Bucket7
    Bucket7 --> Bucket8
    end
